﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/Admin.Master" AutoEventWireup="true"
    CodeBehind="ArticleManage.aspx.cs" Inherits="Hengbei.Web.Admin.ArticleManage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:EntityDataSource ID="edsArticles" runat="server" ConnectionString="name=HengbeiEntities"
        DefaultContainerName="HengbeiEntities" EnableDelete="True" EnableFlattening="False"
        EnableInsert="True" EnableUpdate="True" EntitySetName="Articles" 
        EntityTypeFilter="Article" Include="SiteUser,ArticleCategory">
    </asp:EntityDataSource>
    <asp:ScriptManager ID="smArticles" runat="server">
    </asp:ScriptManager>
    <asp:EntityDataSource ID="edsCategories" runat="server" ConnectionString="name=HengbeiEntities"
        DefaultContainerName="HengbeiEntities" EnableFlattening="False" EntitySetName="ArticleCategories">
    </asp:EntityDataSource>
    <asp:EntityDataSource ID="edsUsers" runat="server" ConnectionString="name=HengbeiEntities"
        DefaultContainerName="HengbeiEntities" EnableFlattening="False" EntitySetName="SiteUsers"
        Select="it.[Name], it.[ID]">
    </asp:EntityDataSource>
    <div style="text-align: center;">
        <h3>
            文章管理</h3>
    </div>
    <br />
    <br />
    <asp:HyperLink ID="hlNewArticle" runat="server" CssClass="Label" Text="插入文章" 
        NavigateUrl="~/Admin/EditArticle.aspx?id=0"></asp:HyperLink>
    <br /><br />
    <asp:Label ID="lblManage" runat="server" CssClass="Label" Text="管理已有文章："></asp:Label>
    <br />
    <asp:UpdatePanel ID="upArticles" runat="server">
        <ContentTemplate>
            <asp:GridView ID="gvArticles" runat="server" AllowPaging="True" AllowSorting="True"
                AutoGenerateColumns="False" CellPadding="4" DataKeyNames="ID" DataSourceID="edsArticles"
                ForeColor="#333333" GridLines="None" Width="100%" 
                onrowdatabound="gvArticles_RowDataBound">
                <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                <Columns>
                    <asp:HyperLinkField InsertVisible="False" Text="编辑" DataNavigateUrlFields="ID" 
                        DataNavigateUrlFormatString="EditArticle.aspx?id={0}" />
                    <asp:CommandField DeleteText="删除" EditText="编辑" ShowDeleteButton="True" />
                    <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True"
                        SortExpression="ID" Visible="False" />
                    <asp:BoundField DataField="CategoryID" HeaderText="CategoryID" SortExpression="CategoryID"
                        Visible="false" />
                    <asp:TemplateField HeaderText="类别" SortExpression="ArticleCategory.Description">
                        <ItemTemplate>
                            <asp:Label ID="lblRole" runat="server" Text='<%# Eval("ArticleCategory.Description") %>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:DropDownList ID="ddlCategories" runat="server" DataSourceID="edsCategories"
                                DataTextField="Description" DataValueField="ID" SelectedValue='<%# Bind("CategoryID") %>'>
                            </asp:DropDownList>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="UserID" HeaderText="UserID" SortExpression="UserID" Visible="false" />
                    <asp:TemplateField HeaderText="用户" SortExpression="SiteUser.Name">
                        <ItemTemplate>
                            <asp:Label ID="lblRole" runat="server" Text='<%# Eval("SiteUser.Name") %>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:DropDownList ID="ddlUsers" runat="server" DataSourceID="edsUsers" DataTextField="Name"
                                DataValueField="ID" SelectedValue='<%# Bind("UserID") %>'>
                            </asp:DropDownList>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="Title" HeaderText="标题" SortExpression="Title" />
                    <asp:BoundField DataField="Body" HeaderText="内容" InsertVisible="False" SortExpression="Body"
                        Visible="False" />
                    <asp:BoundField DataField="CreateDate" HeaderText="创建时间" SortExpression="CreateDate" />
                    <asp:BoundField DataField="LastModifyDate" HeaderText="最后修改" SortExpression="LastModifyDate" />
                </Columns>
                <EditRowStyle BackColor="#999999" />
                <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                <SortedAscendingCellStyle BackColor="#E9E7E2" />
                <SortedAscendingHeaderStyle BackColor="#506C8C" />
                <SortedDescendingCellStyle BackColor="#FFFDF8" />
                <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
            </asp:GridView>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
